package com.tiger.controller;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.tiger.domain.User;
import com.tiger.service.UserService;

@RestController
public class UserController {
	// web访问
	@RequestMapping("hello")
	public String sayHello() {
		return "Hello SpringBoot ...";
	}

	// 返回Json
	@RequestMapping("getList")
	public Object getList() {
		ArrayList<User> arrayList = new ArrayList<User>(2);
		User user1 = new User();
		user1.setUserName("托马斯");
		user1.setAge(25);
		user1.setAddress("北京天河");
		arrayList.add(user1);
		User user2 = new User();
		user2.setUserName("托马斯");
		user2.setAge(25);
		user2.setAddress("北京天河");
		arrayList.add(user2);
		return arrayList;
	}

	@Autowired
	private UserService userServiceImpl;

	// 整合mybatis
	@RequestMapping("findUsers")
	public Object findUsers() {
		System.out.println("start search...");
		return userServiceImpl.findUsers();
	}
}
